Fix application window snapshot differently
authorMatthias Clasen <mclasen@redhat.com>
Sun, 8 Oct 2017 18:03:19 +0000 (14:03 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 8 Oct 2017 18:03:19 +0000 (14:03 -0400)
As Timm Baedert pointed out, the previous fix made the
menubar go on top of popovers, which is just wrong. Instead,
make gtk_window_snapshot handle all direct children of the
window, taking care to stack popovers correctly.

gtk/gtkapplicationwindow.c
gtk/gtkwindow.c

index 8eda444ea57aee8cf8b9f459575352347cf134d9..9c028a24599d0ba5cbfff8ee8fcb5377ff6da09a 100644 (file)
@@ -798,18 +798,6 @@ gtk_application_window_init (GtkApplicationWindow *window)
                             G_CALLBACK (g_action_group_action_removed), window);
 }
 
-static void
-gtk_application_window_snapshot (GtkWidget   *widget,
-                                 GtkSnapshot *snapshot)
-{
-  GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (widget);
-
-  GTK_WIDGET_CLASS (gtk_application_window_parent_class)->snapshot (widget, snapshot);
-
-  if (window->priv->menubar)
-    gtk_widget_snapshot_child (widget, window->priv->menubar, snapshot);
-}
-
 static void
 gtk_application_window_class_init (GtkApplicationWindowClass *class)
 {
@@ -825,7 +813,6 @@ gtk_application_window_class_init (GtkApplicationWindowClass *class)
   widget_class->unrealize = gtk_application_window_real_unrealize;
   widget_class->map = gtk_application_window_real_map;
   widget_class->unmap = gtk_application_window_real_unmap;
-  widget_class->snapshot = gtk_application_window_snapshot;
 
   object_class->get_property = gtk_application_window_get_property;
   object_class->set_property = gtk_application_window_set_property;
index 91b637a4011217caf4e9f89f1b45c8b47737c065..4995e3867d358dee953add55640823d25fb555cc 100644 (file)
@@ -9152,6 +9152,7 @@ gtk_window_snapshot (GtkWidget   *widget,
   gint title_height;
   GList *l;
   int width, height;
+  GtkWidget *child;
 
   context = gtk_widget_get_style_context (widget);
 
@@ -9219,11 +9220,14 @@ gtk_window_snapshot (GtkWidget   *widget,
                              height -
                                (window_border.top + window_border.bottom + title_height));
 
-  if (priv->title_box != NULL)
-    gtk_widget_snapshot_child (widget, priv->title_box, snapshot);
-
-  if (gtk_bin_get_child (GTK_BIN (widget)))
-    gtk_widget_snapshot_child (widget, gtk_bin_get_child (GTK_BIN (widget)), snapshot);
+  for (child = _gtk_widget_get_first_child (widget);
+       child != NULL;
+       child = _gtk_widget_get_next_sibling (child))
+    {
+      /* Handle popovers separately until their stacking order is fixed */
+      if (!GTK_IS_POPOVER (child))
+        gtk_widget_snapshot_child (widget, child, snapshot);
+    }
 
   for (l = priv->popovers.head; l; l = l->next)
     {